home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Library.aspx.cs618 < prev    next >
Text File  |  2008-02-23  |  8KB  |  235 lines

  1. //===========================================================================
  2. // This file was modified as part of an ASP.NET 2.0 Web project conversion.
  3. // The class name was changed and the class modified to inherit from the abstract base class 
  4. // in file 'App_Code\Migrated\Stub_Library_aspx_cs.cs'.
  5. // During runtime, this allows other classes in your web application to bind and access 
  6. // the code-behind page using the abstract base class.
  7. // The associated content page 'Library.aspx' was also modified to refer to the new class name.
  8. // For more information on this code pattern, please refer to http://go.microsoft.com/fwlink/?LinkId=46995 
  9. //===========================================================================
  10. using System;
  11. using System.Collections;
  12. using System.Globalization;
  13. using System.IO;
  14. using System.Text.RegularExpressions;
  15. using System.Web;
  16. using System.Web.UI.WebControls;
  17. using GBPVR.Public;
  18. using gbweb.classes;
  19.  
  20. namespace gbweb
  21. {
  22.     /// <summary>
  23.     /// Summary description for Library.
  24.     /// </summary>
  25.     public partial class Migrated_Library : Library
  26.     {
  27.  
  28.         protected string Mode;
  29.         protected string DisplayPath;
  30.         private Settings guideParams;
  31.  
  32.         protected void Page_Load(object sender, EventArgs e)
  33.         {
  34.             Session["GuideStartTime"] = null;
  35.             playAlbum.Visible = false;
  36.             guideParams = Global.Settings;
  37.             streamAlbum.Visible = false;
  38.             bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
  39.             
  40.             string vpath = string.Empty;
  41.             if ((Request["path"] != null) && (Request["path"].Length != 0))
  42.             {
  43.                 vpath = Request["path"];
  44.             }
  45.             string[] pathparts = vpath.Split(new char[] {'/'}, 3);
  46.             Mode = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(pathparts[0]);
  47.  
  48.             Regex fileFilter = GetRegex(Mode);
  49.  
  50.             header.ActiveTab = Mode.ToLower() + "library";
  51.  
  52.             string path = GetRealPath(vpath);
  53.  
  54.             ArrayList folders = new ArrayList();
  55.             ArrayList files = new ArrayList();
  56.  
  57.             if (pathparts.Length == 1)
  58.             {
  59.                 Hashtable directories = (Hashtable)HttpContext.Current.Session[Mode + "LibraryDirectories"];
  60.                 ArrayList keys = new ArrayList(directories.Keys);
  61.                 keys.Sort();
  62.                 foreach (string name in keys)
  63.                     folders.Add(name);
  64.             }
  65.             else
  66.             {
  67.                 if (pathparts.Length == 2)
  68.                     DisplayPath = " - " + pathparts[1];
  69.                 else if (pathparts.Length == 3) 
  70.                 {
  71.                     DisplayPath = " - " + pathparts[1] + "/" + pathparts[2];
  72.                 }
  73.  
  74.                 try
  75.                 {
  76.                     folders.Add("..");
  77.  
  78.                     string[] dirs = Directory.GetDirectories(path);
  79.                     Array.Sort(dirs);
  80.                     foreach (string dir in dirs)
  81.                     {
  82.                         if (dir == Path.GetFullPath(dir))
  83.                             folders.Add(Path.GetFileName(dir));
  84.                     }
  85.  
  86.                     string[] filenames = Directory.GetFiles(path);
  87.                     Array.Sort(filenames);
  88.                     foreach (string filename in filenames)
  89.                     {
  90.                         if (filename == Path.GetFullPath(filename))
  91.                             files.Add(Path.GetFileName(filename));
  92.                     }
  93.                 }
  94.                 catch (Exception ex)
  95.                 {
  96.                     Logger.Error(ex.ToString());
  97.                 }
  98.             }
  99.  
  100.             string root = string.Join("/", pathparts);
  101.             if (root.Length > 0) root += "/";
  102.  
  103.             TableCell colOpt = new TableCell();
  104.             TableCell colShow = new TableCell();
  105.             TableRow recordingRow;
  106.             foreach (string folder in folders)
  107.             {
  108.  
  109.                 recordingRow = new TableRow();
  110.                 recordingRow.CssClass = "library_row";
  111.  
  112.                 colShow = new TableCell();
  113.                 colShow.VerticalAlign = VerticalAlign.Top;
  114.                 colShow.CssClass = "folder";
  115.  
  116.                 if (folder != "..")
  117.                 {
  118.                     path = Server.UrlEncode(root) + Server.UrlEncode(folder);
  119.                 }
  120.                 else 
  121.                 {
  122.                     path = string.Join("/", pathparts);
  123.                     path = path.Substring(0, path.LastIndexOf("/"));
  124.                     path = Server.UrlEncode(path);
  125.                 }
  126.  
  127.                 colShow.Text = "<a href=\"?path=" + path + "\" >[" + folder + "]</a>";
  128.  
  129.                 recordingRow.Cells.Add(colShow);
  130.  
  131.                 libraryView.Rows.Add(recordingRow);
  132.  
  133.             }
  134.  
  135.             //Need to remove the variable holder since it is only used by the CSS Library display
  136.             Regex coverFilter = new Regex(Global.Settings.coverFiles.Replace("~|", ""), RegexOptions.Compiled | RegexOptions.IgnoreCase);
  137.             string coverImage = null;
  138.             string strmAlbumLink = null;
  139.             foreach (string file in files)
  140.             {
  141.                 if (fileFilter.IsMatch(file))
  142.                 {
  143.                     playAlbum.Visible = true;
  144.                     
  145.                     recordingRow = new TableRow();
  146.                     recordingRow.CssClass = "library_row";
  147.  
  148.                     colShow = new TableCell();
  149.                     colShow.VerticalAlign = VerticalAlign.Top;
  150.                     colShow.CssClass = "file";
  151.  
  152.                     colShow.Text =
  153.                         file + "</a><br></br>";
  154.                         if (strmAllowed)
  155.                         {
  156.                             if (Mode.ToLower() == "music")
  157.                             {
  158.                                 colShow.Text += "<a href=\"public/Player.aspx?playerType=2&mvid=" +
  159.                                                 PublicDownload.Serialize(root + file) +
  160.                                                 "\" onclick=\"EditPop5(this.href,'Add1');return false;\" class=\"btn-normal-small\"><span>Stream</span></a>";
  161.                             }
  162.                             else
  163.                             {
  164.                                 colShow.Text += "<a href=\"public/Player.aspx?playerType=1&mvid=" +
  165.                                                  PublicDownload.Serialize(root + file) +
  166.                                                  "\" onclick=\"EditPop5(this.href,'Add1');return false;\" class=\"btn-normal-small\"><span>Stream</span></a>";
  167.  
  168.                             }
  169.                         }
  170.                         colShow.Text += "<a href=\"" + Download.GetDownloadUrl(false, false, Download.InternalFiles.LibraryFile, root + file) + "\" class=\"btn-normal-small\"><span>Play</span></a>" +
  171.                         "<a href=\"" + Download.GetDownloadUrl(true, true, Download.InternalFiles.LibraryFile, root + file) + "\" class=\"btn-normal-small\"><span>Download</span></a>";
  172.  
  173.                     recordingRow.Cells.Add(colShow);
  174.  
  175.                     libraryView.Rows.Add(recordingRow);
  176.  
  177.                 }
  178.                 if ((coverFilter.IsMatch(file) && (coverImage == null)))
  179.                 {
  180.                     coverImage = Download.GetDownloadUrl(false, true, Download.InternalFiles.LibraryFile, root + file);
  181.                 }
  182.             }
  183.             //strmAlbumLink = "public/Player.aspx?mid=" + PublicDownload.Serialize(root) + "\" onclick=\"EditPop5(this.href,'Add1');return false;\"";
  184.  
  185.             if (coverImage != null)
  186.             {
  187.                 coverArt.Attributes.Add("background", coverImage);
  188.             }
  189.  
  190.             downloadAlbum.Visible = playAlbum.Visible;
  191.             if (playAlbum.Visible)
  192.             {
  193.                 playAlbum.HRef = Download.GetDownloadUrl(false, false, Download.InternalFiles.LibraryFolder, root);
  194.                 downloadAlbum.HRef = Download.GetDownloadUrl(true, true, Download.InternalFiles.LibraryFolder, root);
  195.                 if (strmAllowed)
  196.                 {
  197.                     if (Mode.ToLower() == "music")
  198.                     {
  199.                         streamAlbum.HRef = "public/Player.aspx?playerType=2&mid=" + PublicDownload.Serialize(root) +
  200.                                            "\" onclick=\"EditPop5(this.href,'Add1');return false;\"";
  201.                     }
  202.                     else
  203.                     {
  204.                         streamAlbum.HRef = "public/Player.aspx?playerType=1&mid=" + PublicDownload.Serialize(root) +
  205.                                         "\" onclick=\"EditPop5(this.href,'Add1');return false;\""; 
  206.                     }
  207.                     streamAlbum.Visible = true;
  208.                 }
  209.             } 
  210.  
  211.         }
  212.  
  213.         #region Web Form Designer generated code
  214.         override protected void OnInit(EventArgs e)
  215.         {
  216.             //
  217.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  218.             //
  219.             InitializeComponent();
  220.             base.OnInit(e);
  221.         }
  222.  
  223.         /// <summary>
  224.         /// Required method for Designer support - do not modify
  225.         /// the contents of this method with the code editor.
  226.         /// </summary>
  227.         private void InitializeComponent()
  228.         {
  229.  
  230.         }
  231.         #endregion
  232.     }
  233.  
  234. }
  235.